<?php

namespace App\Http\Controllers;

use App\Http\Request\NameStore;
use App\Http\Request\TestStore;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;

class ExampleController extends Controller
{

    /**
     *
     * 引入两个注入，主要用于长驻内存
     * Created by Paco
     * Date: 2018/8/13
     * Time: 23:30
     * @param Request $request
     * @param TestStore $test
     * @return mixed
     * @throws \Illuminate\Validation\ValidationException
     */
    public function index(Request $request, TestStore $test)
    {

        //$user = DB::table('fs_user')->first();
        //return $this->respondWith($user);
        //$params = $test->validate($request);
        $redis = app('redis');
        $redis->setex('name', 300, 'fucking');
        return $redis->get('name');

    }

    /**
     *
     * getName
     * @author Paco
     * @createTime 2018/8/14 9:57
     * @param Request $request
     * @param NameStore $name
     * @return mixed
     * @throws \Illuminate\Validation\ValidationException
     */
    public function getName(Request $request, NameStore $name)
    {
        $params = $name->validate($request);
        return $params;
    }

    //
}
